package com.mygdx.game.stage;

import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.mygdx.game.MainGame;
import com.mygdx.game.group.DialogGroup;
import com.mygdx.game.stage.base.BaseStage;

public class ExitConfirmStage extends BaseStage {

    //对话框
    private DialogGroup dialogGroup;

    public ExitConfirmStage(MainGame game, Viewport viewport) {
        super(game, viewport);
        init();
    }

    public void init() {
        dialogGroup = new DialogGroup(getMainGame(), "确认退出游戏吗？");
        dialogGroup.setPosition(getWidth() / 2 - dialogGroup.getWidth() / 2, getHeight() / 2 - dialogGroup.getHeight() / 2);
        addActor(dialogGroup);

        addListener(new InputListener() {
            public boolean keyUp(InputEvent event, int keycode) {
                if (keycode == Input.Keys.BACK) {
                    getMainGame().getGameScreen().setShowExitConfirmStage(false);
                }
                return super.keyUp(event, keycode);
            }
        });
    }
}
